/*
 * Copyright (c) 2024. hallele, Inc All rights reserved.
 */

package cn.hallele.infrastructure.metadata.io;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serial;
import java.io.Serializable;
import java.util.List;

/**
 * hallele_mc_core
 *
 * @author anle5
 * @since 2024/11/16 16:51
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Schema(description = "批量操作的结果")
public class BatchResult<T> implements Serializable {
    @Serial
    private static final long serialVersionUID = 9138075980066077881L;

    /**
     * 总数
     */
    @Schema(description = "总数")
    private Integer total;

    /**
     * 成功数
     */
    @Schema(description = "成功数")
    private Integer successNum;

    /**
     * 失败数
     */
    @Schema(description = "失败数")
    private Integer failNum;

    /**
     * 数据
     */
    @Schema(description = "数据")
    private List<Result<T>> data;

    /**
     * 结果详情
     */
    @Data
    @Builder
    @AllArgsConstructor
    @NoArgsConstructor
    @Schema(description = "单条结果详情")
    public static class Result<T> implements Serializable {
        @Serial
        private static final long serialVersionUID = 2279489101589301129L;

        /**
         * 主键
         */
        @Schema(description = "主键")
        private T t;

        /**
         * 结果，true为成功，false为失败
         */
        @Schema(description = "结果，true为成功，false为失败")
        private Boolean result;

        /**
         * 处理结果响应码
         */
        @Schema(description = "处理结果响应码")
        private String msgCode;

        /**
         * 处理结果详细描述
         */
        @Schema(description = "处理结果详细描述")
        private String msgDesc;
    }
}
